/*
 **	Session.h
 **
 **	Published / author: 2006-03-29 / grymse@alhem.net
 **/
/*
Copyright (C) 2006 Anders Hedstrom

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SESSION_H
#define _SESSION_H

#include <string>
#include <vector>


#ifdef ODBCW_NAMESPACE
namespace ODBCW_NAMESPACE {
#endif

class Database;

/** ODBC connection w/ busy state flag. */
class Session
{
public:
	Session();
	virtual ~Session();

	int Connect(Database& ,const std::string&);
	int Connect(Database& ,const std::string& ,const std::string& ,const std::string&);
	void Disconnect();

	void *GetHandle();
	void ShowErrorInfo(SQLRETURN, SQLSMALLINT, SQLHANDLE);

	int GetLastError(std::string& strSqlState, std::string& strErrorMessage);
	void ResetLastError();

	void SetBusy(bool);
	bool IsBusy();

private:
	static SQLHENV m_henv;
	SQLHDBC m_hdbc;
	bool m_bBusy;

	int m_nLastError;
	std::string m_strLastErrorSqlState;
	std::string m_strLastErrorMessage;
};


#ifdef ODBCW_NAMESPACE
} // namespace ODBCW_NAMESPACE {
#endif
#endif // _SESSION_H
